//
//  UrbanDetailsViewController.m
//  UrbanManagement
//
//  Created by Can on 18/4/12.
//  Copyright © 2018年 hwd. All rights reserved.
//

#import "UrbanDetailsViewController.h"

@interface UrbanDetailsViewController ()

@property (nonatomic, strong) NSString *content;

@end

@implementation UrbanDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initTitleWithTitle:@"详情"];
    
    [self getHtmlDetail];
}

- (void)creatView
{
    UIWebView *webView = [[UIWebView alloc]initWithFrame:self.view.bounds];
    
    [webView setBackgroundColor:[UIColor clearColor]];
    [webView setOpaque:NO];
    
    NSString *htmlString = [NSString stringWithFormat:@"<html> \n"
                            "<head> \n"
                            "<style type=\"text/css\"> \n"
                            "body {font-size:15px;}\n"
                            "</style> \n"
                            "</head> \n"
                            "<body>"
                            "<script type='text/javascript'>"
                            "window.onload = function(){\n"
                            "var $img = document.getElementsByTagName('img');\n"
                            "for(var p in $img){\n"
                            " $img[p].style.width = '100%%';\n"
                            "$img[p].style.height ='auto'\n"
                            "}\n"
                            "}"
                            "</script>%@"
                            "</body>"
                            "</html>",_content];
    
    [webView loadHTMLString:htmlString baseURL:nil];
    
    webView.scalesPageToFit = YES;
    
    [self.view addSubview:webView];
}

- (void)getHtmlDetail
{
    [HudHelper showProgressHudWithMessage:@"" toView:self.view];
    
    NSMutableDictionary *dic = [NSMutableDictionary new];
    
    [dic setValue:_ID forKey:@"id"];
    
    [HttpRequest PostrequestUrl:@"jeesite/appInterface/news/newsDetails" Dic:dic completion:^(NSDictionary *responseDic)
     {
//         NSLog(@"responseDic:%@",responseDic);
         [HudHelper hideHudToView:self.view];

         self->_content = [[responseDic objectForKey:@"result"] objectForKey:@"newsContent"];
         [self creatView];
     }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
